<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 6.0.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/all.min.css" integrity="sha256-2H3fkXt6FEmrReK448mDVGKb3WW2ZZw35gI7vqHOE4Y=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"example.com","root":"/","images":"/images","scheme":"Gemini","version":"8.7.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":true,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"Searching...","empty":"We didn't find any results for the search: ${query}","hits_time":"${hits} results found in ${time} ms","hits":"${hits} results found"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>
<meta name="description" content="Never stop learning">
<meta property="og:type" content="website">
<meta property="og:title" content="Xiaolong&#39;s Blog">
<meta property="og:url" content="http://example.com/index.html">
<meta property="og:site_name" content="Xiaolong&#39;s Blog">
<meta property="og:description" content="Never stop learning">
<meta property="og:locale" content="en_US">
<meta property="article:author" content="Xiaolong">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="http://example.com/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":true,"isPost":false,"lang":"en","comments":"","permalink":"","path":"index.html","title":""}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>Xiaolong's Blog</title>
  




  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">Xiaolong's Blog</h1>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu">
        <li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>Home</a></li>
        <li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>Tags</a></li>
        <li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>Archives</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>Search
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="Searching..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-overview-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-overview">
            <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Xiaolong"
      src="/images/lion.jpg">
  <p class="site-author-name" itemprop="name">Xiaolong</p>
  <div class="site-description" itemprop="description">Never stop learning</div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">45</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">17</span>
        <span class="site-state-item-name">tags</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author site-overview-item animated">
      <span class="links-of-author-item">
        <a href="https://github.com/drwna" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;drwna" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>



          </div>
        </div>
      </div>
        <div class="back-to-top animated" role="button" aria-label="Back to top">
          <i class="fa fa-arrow-up"></i>
          <span>0%</span>
        </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="reading-progress-bar"></div>

  <a href="https://github.com/Drwna" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner index posts-expand">

    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/03/07/00/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/lion.jpg">
      <meta itemprop="name" content="Xiaolong">
      <meta itemprop="description" content="Never stop learning">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Xiaolong's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2023/03/07/00/" class="post-title-link" itemprop="url">vim + Vscode / WebStorm</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2023-03-07 00:00:00" itemprop="dateCreated datePublished" datetime="2023-03-07T00:00:00+08:00">2023-03-07</time>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h1 id="Vim-VScode-WebStorm"><a href="#Vim-VScode-WebStorm" class="headerlink" title="Vim + VScode / WebStorm"></a>Vim + VScode / WebStorm</h1><p>使用 vim 快捷键的好处：</p>
<ol>
<li>提高效率。</li>
<li>统一 WebStorm（JetBrains 系列软件） 和 VScode 的快捷键操作。</li>
</ol>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2023/03/07/00/#more" rel="contents">
                Read more &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/01/26/00/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/lion.jpg">
      <meta itemprop="name" content="Xiaolong">
      <meta itemprop="description" content="Never stop learning">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Xiaolong's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2023/01/26/00/" class="post-title-link" itemprop="url">Uniapp 开发记录</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2023-01-26 00:00:00" itemprop="dateCreated datePublished" datetime="2023-01-26T00:00:00+08:00">2023-01-26</time>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h1 id="Uniapp-开发记录"><a href="#Uniapp-开发记录" class="headerlink" title="Uniapp 开发记录"></a><strong>Uniapp</strong> 开发记录</h1><h2 id="使用-Vue3-的-setup-语法糖"><a href="#使用-Vue3-的-setup-语法糖" class="headerlink" title="使用 Vue3 的 setup 语法糖"></a>使用 Vue3 的 setup 语法糖</h2><h2 id="配置跨域代理"><a href="#配置跨域代理" class="headerlink" title="配置跨域代理"></a>配置跨域代理</h2>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2023/01/26/00/#more" rel="contents">
                Read more &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/12/01/00/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/lion.jpg">
      <meta itemprop="name" content="Xiaolong">
      <meta itemprop="description" content="Never stop learning">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Xiaolong's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2022/12/01/00/" class="post-title-link" itemprop="url">Canvas</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2022-12-01 00:00:00" itemprop="dateCreated datePublished" datetime="2022-12-01T00:00:00+08:00">2022-12-01</time>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h1 id="canvas"><a href="#canvas" class="headerlink" title="canvas"></a>canvas</h1><h2 id="创建高清的-canvas"><a href="#创建高清的-canvas" class="headerlink" title="创建高清的 canvas"></a>创建高清的 canvas</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> createHDCanvas = (w, h) = &gt;&#123;</span><br><span class="line">    <span class="keyword">const</span> canvas = <span class="variable language_">document</span>.<span class="title function_">createElement</span>(<span class="string">&quot;canvas&quot;</span>);</span><br><span class="line">    <span class="keyword">const</span> ratio = <span class="variable language_">window</span>.<span class="property">devicePixelRatio</span> || <span class="number">1</span>;</span><br><span class="line">    canvas.<span class="property">width</span> = w * ratio; <span class="comment">// 实际渲染像素</span></span><br><span class="line">    canvas.<span class="property">height</span> = h * ratio; <span class="comment">// 实际渲染像素</span></span><br><span class="line">    canvas.<span class="property">style</span>.<span class="property">width</span> = <span class="string">`<span class="subst">$&#123;w&#125;</span>px`</span>; <span class="comment">// 控制显示大小</span></span><br><span class="line">    canvas.<span class="property">style</span>.<span class="property">height</span> = <span class="string">`<span class="subst">$&#123;h&#125;</span>px`</span>; <span class="comment">// 控制显示大小</span></span><br><span class="line">    <span class="keyword">const</span> ctx = canvas.<span class="title function_">getContext</span>(<span class="string">&quot;2d&quot;</span>);</span><br><span class="line">    ctx.<span class="title function_">scale</span>(ratio, ratio);</span><br><span class="line">    <span class="comment">// canvas 绘制</span></span><br><span class="line">    <span class="keyword">return</span> canvas;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2022/12/01/00/#more" rel="contents">
                Read more &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/03/28/47/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/lion.jpg">
      <meta itemprop="name" content="Xiaolong">
      <meta itemprop="description" content="Never stop learning">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Xiaolong's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2022/03/28/47/" class="post-title-link" itemprop="url">code</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2022-03-28 22:03:47" itemprop="dateCreated datePublished" datetime="2022-03-28T22:03:47+08:00">2022-03-28</time>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <p>常用代码</p>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2022/03/28/47/#more" rel="contents">
                Read more &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/03/04/45/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/lion.jpg">
      <meta itemprop="name" content="Xiaolong">
      <meta itemprop="description" content="Never stop learning">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Xiaolong's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2022/03/04/45/" class="post-title-link" itemprop="url">test</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2022-03-04 18:11:45" itemprop="dateCreated datePublished" datetime="2022-03-04T18:11:45+08:00">2022-03-04</time>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h1 id="test"><a href="#test" class="headerlink" title="test"></a>test</h1>
      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/02/12/20/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/lion.jpg">
      <meta itemprop="name" content="Xiaolong">
      <meta itemprop="description" content="Never stop learning">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Xiaolong's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2022/02/12/20/" class="post-title-link" itemprop="url">wheel ui</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2022-02-12 23:57:20" itemprop="dateCreated datePublished" datetime="2022-02-12T23:57:20+08:00">2022-02-12</time>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h2 id="初始化-vue-router"><a href="#初始化-vue-router" class="headerlink" title="初始化 vue-router"></a>初始化 vue-router</h2><p>新建 history 对象</p>
<p>新建 router 对象</p>
<p>app.use(router)</p>
<figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> history = <span class="title function_">createWebHashHistory</span>();</span><br><span class="line"><span class="keyword">const</span> router = <span class="title function_">createRouter</span>(&#123;</span><br><span class="line">  <span class="attr">history</span>: history,</span><br><span class="line">  <span class="attr">routes</span>: [&#123; <span class="attr">path</span>: <span class="string">&quot;/&quot;</span>, <span class="attr">component</span>: <span class="title class_">HelloWorld</span> &#125;],</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> app = <span class="title function_">createApp</span>(<span class="title class_">App</span>);</span><br><span class="line">app.<span class="title function_">use</span>(router);</span><br><span class="line">app.<span class="title function_">mount</span>(<span class="string">&quot;#app&quot;</span>);</span><br></pre></td></tr></table></figure>

<!--mor

添加 `<router-view>` `<router-link>`

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;</span><br><span class="line">  &lt;div&gt;</span><br><span class="line">    导航栏 |</span><br><span class="line">    &lt;router-link to=&quot;/&quot;&gt; frank &lt;/router-link&gt; |</span><br><span class="line">    &lt;router-link to=&quot;/xxx&quot;&gt; frank2&lt;/router-link&gt;</span><br><span class="line">  &lt;/div&gt;</span><br><span class="line">  &lt;hr /&gt;</span><br><span class="line">  &lt;router-view /&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line"></span><br><span class="line">&lt;script&gt;</span><br><span class="line">export default &#123;</span><br><span class="line">  name: &quot;App&quot;,</span><br><span class="line">&#125;;</span><br><span class="line">&lt;/script&gt;</span><br><span class="line"></span><br></pre></td></tr></table></figure>





<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">yarn global add create-vite-app</span><br><span class="line">cva wheel-ui</span><br><span class="line">// 等价于</span><br><span class="line">npm init vite-app &lt;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">cd wheel-ui</span><br><span class="line">yarn install</span><br><span class="line">yarn dev</span><br><span class="line"></span><br><span class="line">// 查看 vue-router 所有版本号</span><br><span class="line">npm info nue-router versions</span><br><span class="line"></span><br><span class="line">// 安装 vue-router</span><br><span class="line">yarn add vue-router</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">yarn add -D sass</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<blockquote>
<p>vite 文档给出的命令是</p>
<p>npm init vite-app 项目名</p>
<p>yarn create vite-app 项目名</p>
<p>等价于</p>
<p>yarn global creat-vite-app</p>
<p>cva 项目名</p>
<p>也等价于</p>
<p>npx create-vite-app 项目名</p>
<p>即 npx 会帮你全局安装用到的包</p>
</blockquote>
<h2 id="provide-inject"><a href="#provide-inject" class="headerlink" title="provide inject"></a>provide inject</h2><p>需求：点击子组件 A ，隐藏子组件 B 某一内容。</p>
<p>App.vue</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">&lt;script lang=&quot;ts&quot;&gt;</span><br><span class="line">import &#123; provide, ref &#125; from &quot;vue&quot;;</span><br><span class="line">export default &#123;</span><br><span class="line">  name: &quot;App&quot;,</span><br><span class="line">  setup() &#123;</span><br><span class="line">    const asideVisible = ref(false); // set</span><br><span class="line">    provide(&quot;xxx&quot;, asideVisible);</span><br><span class="line">  &#125;,</span><br><span class="line">&#125;;</span><br><span class="line">&lt;/script&gt;</span><br></pre></td></tr></table></figure>


<p>子组件 A</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- Topnav.vue --&gt;</span><br><span class="line">&lt;template&gt;</span><br><span class="line">  &lt;div class=&quot;topnav&quot;&gt;</span><br><span class="line">    &lt;div class=&quot;logo&quot; @click=&quot;toggleAside&quot;&gt;LOGO&lt;/div&gt;</span><br><span class="line">  &lt;/div&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line"></span><br><span class="line">&lt;script lang=&quot;ts&quot;&gt;</span><br><span class="line">import Vue, &#123; inject, Ref &#125; from &quot;vue&quot;;</span><br><span class="line">export default &#123;</span><br><span class="line">  setup() &#123;</span><br><span class="line">    const asideVisible = inject&lt;Ref&lt;boolean&gt;&gt;(&quot;xxx&quot;);</span><br><span class="line">    const toggleAside = () =&gt; &#123;</span><br><span class="line">      asideVisible.value = !asideVisible.value;</span><br><span class="line">    &#125;;</span><br><span class="line">    return &#123; toggleAside &#125;;</span><br><span class="line">  &#125;,</span><br><span class="line">&#125;;</span><br><span class="line">&lt;/script&gt;</span><br></pre></td></tr></table></figure>


<p>子组件 B</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- Doc.vue --&gt;</span><br><span class="line">&lt;template&gt;</span><br><span class="line">  &lt;div&gt;</span><br><span class="line">    &lt;Topnav /&gt;</span><br><span class="line">    &lt;div class=&quot;content&quot;&gt;</span><br><span class="line">      &lt;aside v-if=&quot;asideVisible&quot;&gt;</span><br><span class="line">        ...</span><br><span class="line">      &lt;/aside&gt;</span><br><span class="line">    &lt;/div&gt;</span><br><span class="line">  &lt;/div&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line"></span><br><span class="line">&lt;script lang=&quot;ts&quot;&gt;</span><br><span class="line">import Topnav from &quot;../components/Topnav.vue&quot;;</span><br><span class="line">import &#123; inject, Ref &#125; from &quot;vue&quot;;</span><br><span class="line">export default &#123;</span><br><span class="line">  components: &#123; Topnav &#125;,</span><br><span class="line">  setup() &#123;</span><br><span class="line">    const asideVisible = inject&lt;Ref&lt;boolean&gt;&gt;(&quot;xxx&quot;);</span><br><span class="line">    return &#123; asideVisible &#125;;</span><br><span class="line">  &#125;,</span><br><span class="line">&#125;;</span><br><span class="line">&lt;/script&gt;</span><br></pre></td></tr></table></figure>
































<h2 id="TS-引入-vue文件"><a href="#TS-引入-vue文件" class="headerlink" title="TS 引入 .vue文件"></a>TS 引入 .vue文件</h2><p><strong>找不到模块“./App.vue”或其相应的类型声明。ts(2307)</strong></p>
<p>src 目录下创建以 .d.ts 为结尾的文件</p>
<figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// shims-vue.d.ts</span></span><br><span class="line"><span class="keyword">declare</span> <span class="variable language_">module</span> <span class="string">&#x27;*.vue&#x27;</span> &#123;</span><br><span class="line">    <span class="keyword">import</span> &#123; <span class="title class_">ComponentOptions</span> &#125; <span class="keyword">from</span> <span class="string">&quot;vue&quot;</span>;</span><br><span class="line">    <span class="keyword">const</span> <span class="attr">componentOptions</span>:<span class="title class_">ComponentOptions</span> </span><br><span class="line">    <span class="keyword">export</span> <span class="keyword">default</span> componentOptions</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>





<h2 id="error-Command-failed-with-exit-code-1"><a href="#error-Command-failed-with-exit-code-1" class="headerlink" title="error Command failed with exit code 1."></a>error Command failed with exit code 1.</h2><center><img src="https://cdn.jsdelivr.net/gh/Drwna/image//images/Snipaste_2022-02-08_15-42-14.png" alt="Snipaste_2022-02-08_15-42-14" width="800px"></center>

<center><img src="https://cdn.jsdelivr.net/gh/Drwna/image//images/Snipaste_2022-02-08_15-42-14.png" alt="Snipaste_2022-02-08_15-42-14" width="800px"></center>

<p>解决：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">rm -rf node_modules/</span><br><span class="line">yarn cache clean</span><br><span class="line">yarn install</span><br></pre></td></tr></table></figure>





<h2 id="父子组件通信"><a href="#父子组件通信" class="headerlink" title="父子组件通信"></a>父子组件通信</h2><p>父组件</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;</span><br><span class="line">  &lt;Switch :value=&quot;y&quot; @input=&quot;y = $event&quot; /&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line"></span><br><span class="line">&lt;script lang=&quot;ts&quot;&gt;</span><br><span class="line">import Switch from &quot;../lib/Switch.vue&quot;;</span><br><span class="line">import &#123; ref &#125; from &quot;vue&quot;;</span><br><span class="line">export default &#123;</span><br><span class="line">  components: &#123; Switch &#125;,</span><br><span class="line">  setup() &#123;</span><br><span class="line">    const y = ref(false);</span><br><span class="line">    return &#123; y &#125;;</span><br><span class="line">  &#125;,</span><br><span class="line">&#125;;</span><br><span class="line">&lt;/script&gt;</span><br></pre></td></tr></table></figure>

<p>子组件</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;  &lt;button @click=&quot;toggle&quot; :class=&quot;&#123; checked: value &#125;&quot;&gt;    &lt;span&gt;&lt;/span&gt;  &lt;/button&gt;&lt;/template&gt;&lt;script lang=&quot;ts&quot;&gt;import &#123; ref &#125; from &quot;vue&quot;;export default &#123;  props: &#123;    value: Boolean,  &#125;,  setup(props, context) &#123;    const toggle = () =&gt; &#123;        // 核心      context.emit(&quot;input&quot;, !props.value);    &#125;;    return &#123; toggle &#125;;  &#125;,&#125;;&lt;/script&gt;</span><br></pre></td></tr></table></figure>

<p>或者使用 <strong>v-model</strong></p>
<p>父组件</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;Switch v-model:value=&quot;y&quot; /&gt;</span><br></pre></td></tr></table></figure>

<p>子组件</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">context.emit(&quot;update:value&quot;, !props.value);</span><br></pre></td></tr></table></figure>



<h2 id="属性绑定"><a href="#属性绑定" class="headerlink" title="属性绑定"></a>属性绑定</h2><p>默认所有属性都绑定到根元素。</p>
<p>使用 <code>inheritAttrs: false</code> 可以取消默认绑定。</p>
<p>使用 <code>$attrs</code> 或者 <code>context.attrs</code> 获取所有属性。</p>
<p>使用 <code>v-bind=“$attrs”</code> 批量绑定属性。</p>
<p>使用 <code>cons &#123;size, ...rest&#125; = context.attrs</code> 将属性放分开。</p>
<p><strong>父组件</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">// ButtonDemo.vue</span><br><span class="line">&lt;template&gt;</span><br><span class="line">  &lt;div&gt;Button 示例&lt;/div&gt;</span><br><span class="line">  &lt;h1&gt;示例1&lt;/h1&gt;</span><br><span class="line">  &lt;div&gt;</span><br><span class="line">    &lt;Button @click=&quot;onClick&quot; </span><br><span class="line">            @mouseover=&quot;onClick&quot; </span><br><span class="line">            size=&quot;small&quot;&gt;你好&lt;/Button&gt;</span><br><span class="line">  &lt;/div&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line"></span><br><span class="line">&lt;script lang=&quot;ts&quot;&gt;</span><br><span class="line">import Button from &quot;../lib/Button.vue&quot;;</span><br><span class="line">export default &#123;</span><br><span class="line">  components: &#123; Button &#125;,</span><br><span class="line">  setup() &#123;</span><br><span class="line">    const onClick = () =&gt; &#123;</span><br><span class="line">      alert(&quot;hello&quot;);</span><br><span class="line">    &#125;;</span><br><span class="line">    return &#123; onClick &#125;;</span><br><span class="line">  &#125;,</span><br><span class="line">&#125;;</span><br><span class="line">&lt;/script&gt;</span><br></pre></td></tr></table></figure>

<p><strong>子组件</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">// Button.vue</span><br><span class="line">&lt;template&gt;</span><br><span class="line">  // 将 size 属性绑定到根元素</span><br><span class="line">  &lt;div :size=&quot;size&quot;&gt;</span><br><span class="line">      // 将其余的属性绑定到目标元素</span><br><span class="line">    &lt;button v-bind=&quot;rest&quot;&gt;</span><br><span class="line">      &lt;slot /&gt;</span><br><span class="line">    &lt;/button&gt;</span><br><span class="line">  &lt;/div&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line"></span><br><span class="line">&lt;script lang=&quot;ts&quot;&gt;</span><br><span class="line">export default &#123;</span><br><span class="line">    // 取消默认绑定到根元素</span><br><span class="line">  inheritAttrs: false,</span><br><span class="line">  setup(props, context) &#123;</span><br><span class="line">    const &#123; size, ...rest &#125; = context.attrs;</span><br><span class="line">    return &#123; size, rest &#125;;</span><br><span class="line">  &#125;,</span><br><span class="line">&#125;;</span><br><span class="line">&lt;/script&gt;</span><br></pre></td></tr></table></figure>



<h2 id="开发-UI-库的-CSS-注意事项"><a href="#开发-UI-库的-CSS-注意事项" class="headerlink" title="开发 UI 库的 CSS 注意事项"></a>开发 UI 库的 CSS 注意事项</h2><p><strong>不能使用 scoped</strong></p>
<p>因为 data-v-xxx 中的 xxx 不能保证每次运行都相同，必须输出稳定不变的 class 选择器，方便使用者覆盖。</p>
<p><strong>必须加前缀</strong></p>
<p>.button 不行，很容易被使用者覆盖，.wheel-button 行，不太容易被覆盖。</p>
<p>.theme-link 不行，很容易被使用者覆盖，.wheel-theme-link 行，不太容易被覆盖。</p>
<h2 id="插槽"><a href="#插槽" class="headerlink" title="插槽"></a>插槽</h2><p>具名插槽</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;       &lt;div class=&quot;wheel-dialog&quot;&gt;    &lt;header&gt;              &lt;slot name=&quot;title&quot;/&gt;      &lt;span @click=&quot;close&quot;&gt;&lt;/span&gt;    &lt;/header&gt;    &lt;main&gt;      &lt;slot name=&quot;content&quot;/&gt;    &lt;/main&gt;      &lt;/template&gt;</span><br></pre></td></tr></table></figure>

<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;  &lt;div&gt;          &lt;template v-slot:content&gt;      &lt;div&gt;你好&lt;/div&gt;      &lt;div&gt;hello&lt;/div&gt;    &lt;/template&gt;    &lt;template v-slot:title&gt;      &lt;strong&gt;xxx&lt;/strong&gt;    &lt;/template&gt;  &lt;/div&gt;&lt;/template&gt;</span><br></pre></td></tr></table></figure>





<h2 id="Teleport"><a href="#Teleport" class="headerlink" title="Teleport"></a>Teleport</h2><p>将 xxx 传送到 body 下</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;Teleport to=&quot;body&quot;&gt;    xxx&lt;/Teleport&gt;</span><br></pre></td></tr></table></figure>





<h2 id="openDialog"><a href="#openDialog" class="headerlink" title="openDialog"></a>openDialog</h2><p>openDialog.js</p>
<figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> <span class="title class_">Dialog</span> <span class="keyword">from</span> <span class="string">&#x27;./Dialog.vue&#x27;</span>;<span class="keyword">import</span> &#123;createApp, h&#125; <span class="keyword">from</span> <span class="string">&#x27;vue&#x27;</span>;<span class="keyword">export</span> <span class="keyword">const</span> <span class="title function_">openDialog</span> = (<span class="params">options</span>) =&gt; &#123;  <span class="keyword">const</span> &#123;title, content, closeOnClickOverlay, ok, cancel&#125; = options;  <span class="keyword">const</span> div = <span class="variable language_">document</span>.<span class="title function_">createElement</span>(<span class="string">&#x27;div&#x27;</span>);  <span class="variable language_">document</span>.<span class="property">body</span>.<span class="title function_">appendChild</span>(div);  <span class="keyword">const</span> <span class="title function_">close</span> = (<span class="params"></span>) =&gt; &#123;    <span class="comment">//@ts-ignore    app.unmount(div);    div.remove();  &#125;;  const app = createApp(&#123;    render() &#123;      return h(Dialog, &#123;        visible: true,        closeOnClickOverlay,        &#x27;onUpdate:visible&#x27;: (newVisible) =&gt; &#123;if (newVisible === false) close(); &#125;,        ok,        cancel      &#125;, &#123;title, content&#125;);    &#125;  &#125;);  app.mount(div);&#125;;</span></span><br></pre></td></tr></table></figure>



<p>vue 组件使用</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> <span class="title function_">showDialog</span> = (<span class="params"></span>) =&gt; &#123;      <span class="title function_">openDialog</span>(&#123;        <span class="attr">title</span>: <span class="string">&#x27;标题&#x27;</span>,        <span class="attr">content</span>: <span class="string">&#x27;你好啊&#x27;</span>,        <span class="attr">closeOnClickOverlay</span>: <span class="literal">false</span>,        <span class="title function_">ok</span>(<span class="params"></span>) &#123;<span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">&#x27;ok&#x27;</span>);&#125;,        <span class="title function_">cancel</span>(<span class="params"></span>) &#123;<span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">&#x27;cancel&#x27;</span>);&#125;      &#125;);    &#125;;</span><br></pre></td></tr></table></figure>



<h2 id="检查子组件的类型"><a href="#检查子组件的类型" class="headerlink" title="检查子组件的类型"></a>检查子组件的类型</h2><p>获取插槽内容 <code>const defaults = context.slots.default()</code></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;  &lt;div&gt;    Tabs 组件  &lt;/div&gt;  &lt;component :is=&quot;defaults[0]&quot;/&gt;  &lt;component :is=&quot;defaults[1]&quot;/&gt;&lt;/template&gt;&lt;script lang=&quot;ts&quot;&gt;import Tab from &#x27;../lib/Tab.vue&#x27;;export default &#123;  setup(props, context) &#123;    // 调试 检查子组件是否为 Tab 组件    // console.log(&#123;...context.slots.default()[0]&#125;);    // console.log(&#123;...context.slots.default()[1]&#125;);    // const defaults = context.slots.default();    // console.log(defaults[0].type === Tab);    const defaults = context.slots.default();    defaults.forEach(tag =&gt; &#123;      if (tag.type !== Tab) &#123;        throw new Error(&#x27;Tabs 子标签必须是 Tab&#x27;);      &#125;    &#125;);    return &#123;defaults&#125;;  &#125;&#125;;&lt;/script&gt;</span><br></pre></td></tr></table></figure>

<p>获取 el 的 width、left <code>const &#123;width, height, left, top&#125; = el.getBoundingClientRect()</code></p>
<h2 id="CSS-最小影响原则"><a href="#CSS-最小影响原则" class="headerlink" title="CSS 最小影响原则"></a>CSS 最小影响原则</h2><p>css 绝对不能影响库的使用者。</p>
<h2 id="markdown"><a href="#markdown" class="headerlink" title="markdown"></a>markdown</h2><p><code>yarn add --dev marked</code></p>
<p>新建 plugins/md.ts</p>
<figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// @ts-nocheck</span></span><br><span class="line"><span class="keyword">import</span> path <span class="keyword">from</span> <span class="string">&#x27;path&#x27;</span>;</span><br><span class="line"><span class="keyword">import</span> fs <span class="keyword">from</span> <span class="string">&#x27;fs&#x27;</span>;</span><br><span class="line"><span class="keyword">import</span> &#123; marked &#125; <span class="keyword">from</span> <span class="string">&#x27;marked&#x27;</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> <span class="title function_">mdToJs</span> = str =&gt; &#123;</span><br><span class="line">  <span class="keyword">const</span> content = <span class="title class_">JSON</span>.<span class="title function_">stringify</span>(<span class="title function_">marked</span>(str));</span><br><span class="line">  <span class="keyword">return</span> <span class="string">`export default <span class="subst">$&#123;content&#125;</span>`</span>;</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">function</span> <span class="title function_">md</span>(<span class="params"></span>) &#123;</span><br><span class="line">  <span class="keyword">return</span> &#123;</span><br><span class="line">    <span class="attr">configureServer</span>: [ <span class="comment">// 用于开发</span></span><br><span class="line">      <span class="keyword">async</span> (&#123;app&#125;) =&gt; &#123;</span><br><span class="line">        app.<span class="title function_">use</span>(<span class="keyword">async</span> (ctx, next) =&gt; &#123; <span class="comment">// koa</span></span><br><span class="line">          <span class="keyword">if</span> (ctx.<span class="property">path</span>.<span class="title function_">endsWith</span>(<span class="string">&#x27;.md&#x27;</span>)) &#123;</span><br><span class="line">            ctx.<span class="property">type</span> = <span class="string">&#x27;js&#x27;</span>;</span><br><span class="line">            <span class="keyword">const</span> filePath = path.<span class="title function_">join</span>(process.<span class="title function_">cwd</span>(), ctx.<span class="property">path</span>);</span><br><span class="line">            ctx.<span class="property">body</span> = <span class="title function_">mdToJs</span>(fs.<span class="title function_">readFileSync</span>(filePath).<span class="title function_">toString</span>());</span><br><span class="line">          &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">            <span class="keyword">await</span> <span class="title function_">next</span>();</span><br><span class="line">          &#125;</span><br><span class="line">        &#125;);</span><br><span class="line">      &#125;,</span><br><span class="line">    ],</span><br><span class="line">    <span class="attr">transforms</span>: [&#123;  <span class="comment">// 用于 rollup // 插件</span></span><br><span class="line">      <span class="attr">test</span>: <span class="function"><span class="params">context</span> =&gt;</span> context.<span class="property">path</span>.<span class="title function_">endsWith</span>(<span class="string">&#x27;.md&#x27;</span>),</span><br><span class="line">      <span class="attr">transform</span>: <span class="function">(<span class="params">&#123;code&#125;</span>) =&gt;</span> <span class="title function_">mdToJs</span>(code)</span><br><span class="line">    &#125;]</span><br><span class="line">  &#125;;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>新建 vite.config.ts</p>
<figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> &#123;md&#125; <span class="keyword">from</span> <span class="string">&#x27;./plugins/md&#x27;</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> &#123;</span><br><span class="line">  <span class="attr">plugins</span>: [<span class="title function_">md</span>()]</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<p>使用</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;</span><br><span class="line">  &lt;article class=&quot;markdown-body&quot; v-html=&quot;md&quot;&gt;&lt;/article&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line">&lt;script lang=&quot;ts&quot;&gt;</span><br><span class="line">// intro.md 为写好的 markdown文件</span><br><span class="line">import md from &#x27;../markdown/intro.md&#x27;;</span><br><span class="line">    </span><br><span class="line">export default &#123;</span><br><span class="line">  data() &#123; return &#123;md&#125;; &#125;</span><br><span class="line">&#125;;</span><br><span class="line">&lt;/script&gt;</span><br></pre></td></tr></table></figure>





<h2 id="消除重复-markdown"><a href="#消除重复-markdown" class="headerlink" title="消除重复 markdown"></a>消除重复 markdown</h2><p>使用动态引入 <code>import()</code>  ==异步操作==</p>
<p>Markdown.vue</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;</span><br><span class="line">  &lt;article class=&quot;markdown-body&quot; v-html=&quot;content&quot;&gt;&lt;/article&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line"></span><br><span class="line">&lt;script lang=&quot;ts&quot;&gt;</span><br><span class="line">import &#123;ref&#125; from &#x27;vue&#x27;;</span><br><span class="line">export default &#123;</span><br><span class="line">  props: &#123;</span><br><span class="line">    path: &#123;</span><br><span class="line">      type: String,</span><br><span class="line">      required: true</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;,</span><br><span class="line">  setup(props) &#123;</span><br><span class="line">     // 核心</span><br><span class="line">    const content = ref&lt;string&gt;();</span><br><span class="line">    import(props.path).then(result =&gt; &#123;</span><br><span class="line">      console.log(result.default);</span><br><span class="line">        // 动态引用 3s 后才会出现</span><br><span class="line">      setTimeout(() =&gt; &#123;</span><br><span class="line">        content.value = result.default;</span><br><span class="line">      &#125;, 3000);</span><br><span class="line">    &#125;);</span><br><span class="line">    return &#123;content&#125;;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;;</span><br><span class="line">&lt;/script&gt;</span><br></pre></td></tr></table></figure>

<p>使用</p>
<p>Intro.vue</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;  &lt;Markdown path=&quot;../markdown/intro.md&quot;/&gt;&lt;/template&gt;&lt;script lang=&quot;ts&quot;&gt;import Markdown from &#x27;../components/Markdown.vue&#x27;;export default &#123;components: &#123;Markdown&#125;,&#125;;&lt;/script&gt;</span><br></pre></td></tr></table></figure>

<p>或者直接全局引入 Markdown 组件，就不需要每个组件单独引入了。</p>
<p>main.ts <code>app.component(&#39;Markdown&#39;, Markdown)</code></p>
<p><strong>进一步优化：</strong></p>
<p>直接在 router.js 里渲染，删除无用的 intro.vue</p>
<figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> history = <span class="title function_">createWebHashHistory</span>();<span class="comment">// 核心const md = filename =&gt; h(Markdown, &#123;path: `../markdown/$&#123;filename&#125;.md`, key: filename&#125;);export const router = createRouter(&#123;  history: history,  routes: [    &#123;path: &#x27;/&#x27;, component: Home&#125;,    &#123;      path: &#x27;/doc&#x27;,      component: Doc,      children: [        &#123;path: &#x27;&#x27;, component: DocDemo&#125;,          // 核心        &#123;path: &#x27;intro&#x27;, component: md(&#x27;intro&#x27;)&#125;,        &#123;path: &#x27;install&#x27;, component: md(&#x27;install&#x27;)&#125;,        &#123;path: &#x27;get-started&#x27;, component: md(&#x27;get-started&#x27;)&#125;,          //        &#123;path: &#x27;switch&#x27;, component: SwitchDemo&#125;,          ...      ],    &#125;,  ],&#125;);</span></span><br></pre></td></tr></table></figure>



<h2 id="展示源代码"><a href="#展示源代码" class="headerlink" title="展示源代码"></a>展示源代码</h2><p>配置 vite.config.ts</p>
<figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> &#123;md&#125; <span class="keyword">from</span> <span class="string">&#x27;./plugins/md&#x27;</span>;<span class="keyword">import</span> * <span class="keyword">as</span> fs <span class="keyword">from</span> <span class="string">&#x27;fs&#x27;</span>;<span class="keyword">import</span> &#123;baseParse&#125; <span class="keyword">from</span> <span class="string">&#x27;@vue/compiler-core&#x27;</span>;<span class="keyword">export</span> <span class="keyword">default</span> &#123;  <span class="attr">plugins</span>: [<span class="title function_">md</span>()],  <span class="attr">vueCustomBlockTransforms</span>: &#123;    <span class="attr">demo</span>: <span class="function">(<span class="params">options</span>) =&gt;</span> &#123;      <span class="keyword">const</span> &#123;code, path&#125; = options;      <span class="keyword">const</span> file = fs.<span class="title function_">readFileSync</span>(path).<span class="title function_">toString</span>();      <span class="comment">//@ts-ignore      const parsed = baseParse(file).children.find(n =&gt; n.tag === &#x27;demo&#x27;);      //@ts-ignore      const title = parsed.children[0].content;      const main = file.split(parsed.loc.source).join(&#x27;&#x27;).trim();      return `export default function (Component) &#123;        Component.__sourceCode = $&#123;        JSON.stringify(main)      &#125;        Component.__sourceCodeTitle = $&#123;JSON.stringify(title)&#125;      &#125;`.trim();    &#125;  &#125;&#125;;</span></span><br></pre></td></tr></table></figure>

<p>SwitchDemo.vue</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;template&gt;  &lt;div&gt;    &lt;div class=&quot;demo-code&quot;&gt;        &lt;!-- 用法 --&gt;      &lt;pre&gt;&#123;&#123; Switch1Demo.__sourceCode &#125;&#125;&lt;/pre&gt;    &lt;/div&gt;  &lt;/div&gt;&lt;/template&gt;&lt;script lang=&quot;ts&quot;&gt;export default &#123;  components: &#123;Switch2Demo, Switch1Demo,Switch,Button&#125;,  setup() &#123;    const bool = ref(false);    return &#123;bool, Switch1Demo, Switch2Demo&#125;;  &#125;&#125;;&lt;/script&gt;</span><br></pre></td></tr></table></figure>

<p>Switch1Demo.vue 组件开头添加上 <code>&lt;demo&gt;xxx&lt;/demo&gt;</code></p>
<h2 id="高亮源代码"><a href="#高亮源代码" class="headerlink" title="高亮源代码"></a>高亮源代码</h2><p>使用 prismjs</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">yarn add prismjs</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">导入</span><br><span class="line">import Prism from &#x27;prismjs&#x27;;</span><br><span class="line">import &#x27;../../node_modules/prismjs/themes/prism.min.css&#x27;;</span><br><span class="line"></span><br><span class="line">...</span><br><span class="line">set()&#123;</span><br><span class="line">return (Prism)</span><br><span class="line">&#125;</span><br><span class="line">...</span><br><span class="line"></span><br><span class="line">使用</span><br><span class="line">&lt;pre class=&quot;language-css&quot; v-html=&quot;Prism.highlight(Switch1Demo.__sourceCode, Prism.languages.html, &#x27;html&#x27;)&quot;/&gt;</span><br><span class="line"></span><br></pre></td></tr></table></figure>







<h2 id="Vue2-和-Vue3-的区别"><a href="#Vue2-和-Vue3-的区别" class="headerlink" title="Vue2 和 Vue3 的区别"></a>Vue2 和 Vue3 的区别</h2><ul>
<li>Vue3 的 template 支持==多个跟标签==，Vue2 不支持。</li>
<li>Vue3 有 <code>createApp()</code> ，而Vue2 的是 <code>new Vue()</code></li>
<li>Vue3 <code>createApp(组件)</code>，Vue2 <code>new Vue(&#123;template, render&#125;)</code></li>
</ul>
<p>v-model 代替以前的 <del>v-model</del>，<del>.sync</del>。</p>
<p>新增 context.emit 和 this.$emit 作用相同。</p>
<h2 id="部署上线注意事项"><a href="#部署上线注意事项" class="headerlink" title="部署上线注意事项"></a>部署上线注意事项</h2><p>配置 vite.config.ts</p>
<p>添加以下代码，</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">base: &#x27;./&#x27;,</span><br><span class="line">assetsDir: &#x27;assets&#x27;,</span><br></pre></td></tr></table></figure>





<h2 id="报错"><a href="#报错" class="headerlink" title="报错"></a>报错</h2><p>runtime-core.esm-bundler.js?5c40:38 [Vue warn]: Invalid VNode type: Symbol(Comment) (symbol) </p>
<center><img src="https://cdn.jsdelivr.net/gh/Drwna/image//images/Snipaste_2022-02-15_20-47-46.png" alt="Snipaste_2022-02-15_20-47-46" width="800px"></center>

<p>解决：</p>
<p>vue.config.js</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> path = <span class="built_in">require</span>(<span class="string">`path`</span>);</span><br><span class="line"></span><br><span class="line"><span class="variable language_">module</span>.<span class="property">exports</span> = &#123;</span><br><span class="line">    <span class="attr">configureWebpack</span>: &#123;</span><br><span class="line">        <span class="attr">resolve</span>: &#123;</span><br><span class="line">            <span class="attr">symlinks</span>: <span class="literal">false</span>,</span><br><span class="line">            <span class="attr">alias</span>: &#123;</span><br><span class="line">                <span class="attr">vue</span>: path.<span class="title function_">resolve</span>(<span class="string">`./node_modules/vue`</span>)</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>



<p>打包部署</p>
<p>rollup -c</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;name&quot;</span><span class="punctuation">:</span> <span class="string">&quot;whl-ui&quot;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;version&quot;</span><span class="punctuation">:</span> <span class="string">&quot;0.0.2&quot;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;files&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line">    <span class="string">&quot;dist/lib/*&quot;</span></span><br><span class="line">  <span class="punctuation">]</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;main&quot;</span><span class="punctuation">:</span> <span class="string">&quot;dist/lib/whl.js&quot;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;scripts&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;dev&quot;</span><span class="punctuation">:</span> <span class="string">&quot;vite&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;build&quot;</span><span class="punctuation">:</span> <span class="string">&quot;vite build&quot;</span></span><br><span class="line">  <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;resolutions&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;node-sass&quot;</span><span class="punctuation">:</span> <span class="string">&quot;npm:sass@^1.26.11&quot;</span></span><br><span class="line">  <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;dependencies&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;github-markdown-css&quot;</span><span class="punctuation">:</span> <span class="string">&quot;4.0.0&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;marked&quot;</span><span class="punctuation">:</span> <span class="string">&quot;4.0.12&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;prismjs&quot;</span><span class="punctuation">:</span> <span class="string">&quot;1.21.0&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;vue&quot;</span><span class="punctuation">:</span> <span class="string">&quot;3.0.0&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;vue-router&quot;</span><span class="punctuation">:</span> <span class="string">&quot;4.0.0-beta.3&quot;</span></span><br><span class="line">  <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;devDependencies&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;@types/prismjs&quot;</span><span class="punctuation">:</span> <span class="string">&quot;^1.26.0&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;@vue/compiler-sfc&quot;</span><span class="punctuation">:</span> <span class="string">&quot;3.0.0&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;rollup-plugin-esbuild&quot;</span><span class="punctuation">:</span> <span class="string">&quot;2.5.0&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;rollup-plugin-scss&quot;</span><span class="punctuation">:</span> <span class="string">&quot;2.6.0&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;rollup-plugin-terser&quot;</span><span class="punctuation">:</span> <span class="string">&quot;7.0.2&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;rollup-plugin-vue&quot;</span><span class="punctuation">:</span> <span class="string">&quot;6.0.0-beta.10&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;sass&quot;</span><span class="punctuation">:</span> <span class="string">&quot;1.26.11&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;vite&quot;</span><span class="punctuation">:</span> <span class="string">&quot;1.0.0-rc.1&quot;</span></span><br><span class="line">  <span class="punctuation">&#125;</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br></pre></td></tr></table></figure>



<p>yarn build</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;name&quot;</span><span class="punctuation">:</span> <span class="string">&quot;whl-ui&quot;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;version&quot;</span><span class="punctuation">:</span> <span class="string">&quot;0.0.2&quot;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;files&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line">    <span class="string">&quot;dist/lib/*&quot;</span></span><br><span class="line">  <span class="punctuation">]</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;main&quot;</span><span class="punctuation">:</span> <span class="string">&quot;dist/lib/whl.js&quot;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;scripts&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;dev&quot;</span><span class="punctuation">:</span> <span class="string">&quot;vite&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;build&quot;</span><span class="punctuation">:</span> <span class="string">&quot;vite build&quot;</span></span><br><span class="line">  <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;resolutions&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;node-sass&quot;</span><span class="punctuation">:</span> <span class="string">&quot;npm:sass@^1.26.11&quot;</span></span><br><span class="line">  <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;dependencies&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;github-markdown-css&quot;</span><span class="punctuation">:</span> <span class="string">&quot;4.0.0&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;marked&quot;</span><span class="punctuation">:</span> <span class="string">&quot;4.0.12&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;prismjs&quot;</span><span class="punctuation">:</span> <span class="string">&quot;1.21.0&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;vue&quot;</span><span class="punctuation">:</span> <span class="string">&quot;^3.0.0&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;vue-router&quot;</span><span class="punctuation">:</span> <span class="string">&quot;4.0.0-beta.3&quot;</span></span><br><span class="line">  <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;devDependencies&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;@types/prismjs&quot;</span><span class="punctuation">:</span> <span class="string">&quot;^1.26.0&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;@vue/compiler-sfc&quot;</span><span class="punctuation">:</span> <span class="string">&quot;^3.0.0&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;rollup-plugin-esbuild&quot;</span><span class="punctuation">:</span> <span class="string">&quot;2.5.0&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;rollup-plugin-scss&quot;</span><span class="punctuation">:</span> <span class="string">&quot;2.6.0&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;rollup-plugin-terser&quot;</span><span class="punctuation">:</span> <span class="string">&quot;7.0.2&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;rollup-plugin-vue&quot;</span><span class="punctuation">:</span> <span class="string">&quot;6.0.0-beta.10&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;sass&quot;</span><span class="punctuation">:</span> <span class="string">&quot;1.26.11&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;vite&quot;</span><span class="punctuation">:</span> <span class="string">&quot;1.0.0-rc.13&quot;</span></span><br><span class="line">  <span class="punctuation">&#125;</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>区别：</p>
<center><img src="https://cdn.jsdelivr.net/gh/Drwna/image//images/Snipaste_2022-02-15_23-23-16.png" alt="Snipaste_2022-02-15_23-23-16" width="600px"></center>




























































































































      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/02/05/08/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/lion.jpg">
      <meta itemprop="name" content="Xiaolong">
      <meta itemprop="description" content="Never stop learning">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Xiaolong's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2022/02/05/08/" class="post-title-link" itemprop="url">大屏可视化项</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2022-02-05 19:33:08" itemprop="dateCreated datePublished" datetime="2022-02-05T19:33:08+08:00">2022-02-05</time>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <p><a target="_blank" rel="noopener" href="https://draganet.gitee.io/bigscreen-website/#/">预览链接</a></p>
<center><img src="https://cdn.jsdelivr.net/gh/Drwna/image//images/Snipaste_2022-02-06_00-16-58.png" alt="Snipaste_2022-02-06_00-16-58" width="800px"></center>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2022/02/05/08/#more" rel="contents">
                Read more &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/01/28/27/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/lion.jpg">
      <meta itemprop="name" content="Xiaolong">
      <meta itemprop="description" content="Never stop learning">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Xiaolong's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2022/01/28/27/" class="post-title-link" itemprop="url">随手记 React 总结</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2022-01-28 00:34:27" itemprop="dateCreated datePublished" datetime="2022-01-28T00:34:27+08:00">2022-01-28</time>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h4 id="CSS-normalize"><a href="#CSS-normalize" class="headerlink" title="CSS normalize"></a>CSS normalize</h4><p><a target="_blank" rel="noopener" href="https://create-react-app.dev/docs/adding-css-reset/">adding CSS Reset</a></p>
<p>在 index.css 中添加 <code>@import-normalize;</code> 即可。</p>
<p>作用是保证页面在不同浏览器上默认样式相近。</p>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2022/01/28/27/#more" rel="contents">
                Read more &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/01/17/52/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/lion.jpg">
      <meta itemprop="name" content="Xiaolong">
      <meta itemprop="description" content="Never stop learning">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Xiaolong's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2022/01/17/52/" class="post-title-link" itemprop="url">随手记 Vue 总结</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2022-01-17 22:33:52" itemprop="dateCreated datePublished" datetime="2022-01-17T22:33:52+08:00">2022-01-17</time>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h2 id="Vue-组件的三种方式（单文件组件）"><a href="#Vue-组件的三种方式（单文件组件）" class="headerlink" title="Vue 组件的三种方式（单文件组件）"></a>Vue 组件的三种方式（单文件组件）</h2><ol>
<li><p>用 JS 对象</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">export default &#123; data, props, methods, created, ...&#125;</span><br></pre></td></tr></table></figure></li>
<li><p>用 TS 类 <code>&lt;script lang=&quot;ts&quot;&gt;</code></p>
<figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Component</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> <span class="keyword">class</span> <span class="title class_">XXX</span> <span class="keyword">extends</span> <span class="title class_ inherited__">Vue</span>&#123;</span><br><span class="line">    <span class="attr">xxx</span>: <span class="built_in">string</span> = <span class="string">&#x27;hello&#x27;</span>;</span><br><span class="line">    <span class="meta">@Prop</span>(<span class="title class_">Number</span>) <span class="attr">xxx</span>: <span class="built_in">number</span> | <span class="literal">undefined</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></li>
<li><p>用 JS 类 <code>&lt;script lang=&quot;js&quot;&gt;</code></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">@<span class="title class_">Component</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> <span class="keyword">class</span> <span class="title class_">XXX</span> <span class="keyword">extends</span> <span class="title class_ inherited__">Vue</span>&#123;</span><br><span class="line">    xxx = <span class="string">&#x27;hi&#x27;</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></li>
</ol>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2022/01/17/52/#more" rel="contents">
                Read more &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/01/16/26/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/lion.jpg">
      <meta itemprop="name" content="Xiaolong">
      <meta itemprop="description" content="Never stop learning">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Xiaolong's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2022/01/16/26/" class="post-title-link" itemprop="url">Web性能优化常见技巧</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2022-01-16 11:23:26" itemprop="dateCreated datePublished" datetime="2022-01-16T11:23:26+08:00">2022-01-16</time>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h1 id="常见技巧"><a href="#常见技巧" class="headerlink" title="常见技巧"></a>常见技巧</h1><p>输入网址后浏览器的做了什么：</p>
<p>1.DNS域名解析；<br>2.建立TCP连接；<br>3.发送HTTP请求；<br>4.服务器处理请求；<br>5.返回响应结果；<br>6.关闭TCP连接；<br>7.浏览器解析HTML；<br>8.浏览器布局渲染；</p>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2022/01/16/26/#more" rel="contents">
                Read more &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




  <nav class="pagination">
    <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><span class="space">&hellip;</span><a class="page-number" href="/page/5/">5</a><a class="extend next" rel="next" href="/page/2/"><i class="fa fa-angle-right" aria-label="Next page"></i></a>
  </nav>

</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 2021 – 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Xiaolong</span>
</div>

    </div>
  </footer>

  
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script>

  
<script src="/js/third-party/search/local-search.js"></script>




  





</body>
</html>
